<?php
	require_once('core.php');

	$codes = array('nc_a = [];');

	set_time_limit(0);

	$area = Model()->query("select * from ra_area");
	$arr = array();
	foreach($area as $key => $val){
		$arr[$val['area_parent_id']] = $arr[$val['area_parent_id']] or $arr[$val['area_parent_id']] = array();
		$arr[$val['area_parent_id']][] = array($val['area_id'],$val['area_name']);
	}

	// unset($arr[0]);
	// foreach($arr as $key => $val){
		// sort($arr[$key])
	// }
	foreach($arr as $key => $val){
		$temp = array();
		foreach($val as $v){
			$temp[] = '[' . $v[0] . ',"' . $v[1] . '"]';
		}
		$codes[] = 'nc_a[' . $key . '] = [' . implode(',',$temp) . '];';   
	}


	echo implode('<br>',$codes);
	// print_r($codes);
?>